angular.module('wf-utils')
.service('qygConfiguration', ($rootScope, $http,userData)->
    loadValidator=()->
        $rootScope.phoneVd=/^1+\d{10}$/
        $rootScope.phonePlusVd=/^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|176|173|178)+\d{8}$|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/
        $rootScope.idCardVd=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
        $rootScope.imgFileVd=/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/
        $rootScope.sortVd=/^[1-9][0-9]{0,5}$/
        $rootScope.posIntVd=/^[1-9][0-9]{0,5}$/
        $rootScope.priceVd=/^0$|^[1-9][0-9]{0,7}(.[0-9]{1,2})?$/
    loadContractChannel=()->
        $rootScope.contractChannel=[]
        $http.get("/dictionary?dicIndex=21",params:{page:0,size:999})
        .success((resp)->
            if resp.code==0
                list=[]
                _.each resp.message.content,(item)->
                    list.push({value:item.code,name:item.name})
                $rootScope.contractChannel=list
        )
    loadCity=()->
        $rootScope.qgyCity=[]
        $http.get("/dictionary?dicIndex=23",params:{page:0,size:999})
        .success((resp)->
            if resp.code==0
                list=[]
                _.each resp.message.content,(item)->
                    if Number(item.remark)
                        list.push({value:Number(item.remark),name:item.name})
                $rootScope.qgyCity=list
        )
    loadOtherParam=()->
        $rootScope.pickMonth = {
            datepickerMode: 'month',
            minMode: 'month'
        }
    init:()->
        ##获取门店权限
        $rootScope.storeAu=userData.getStore()
        ##加载统一校验规则
        loadValidator()
        ##加载合同渠道字典表配置
        loadContractChannel()
        ##加载城市列表字典表配置
        loadCity()
        loadOtherParam()
)
